package com.maxd.modules.selfshop.merchants.controller;

import com.maxd.adapter.IgnoreSecurity;
import com.maxd.error.Result;
import com.maxd.modules.selfshop.merchants.entity.SelfStoreComplain;
import com.maxd.modules.selfshop.merchants.service.SelfStoreComplainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value="自营商城店铺投诉管理",tags={"自营商城店铺投诉管理"})
@RequestMapping(value = "/self/storeComplain")
public class SelfStoreComplainController {
    @Autowired
    private SelfStoreComplainService service;

    @IgnoreSecurity
    @GetMapping("/list")
    @ApiOperation("列表")
    public Result findAll(Integer page, Integer size,
                          @ApiParam("店铺名称") String storeName,
                          @ApiParam("状态（0全部 1待处理 2投诉驳回 3商家处理中 4商家已处理 5总后台已处理）") Integer status) {
        return service.findAll(page, size, storeName, status);
    }

    @IgnoreSecurity
    @GetMapping("/storeList")
    @ApiOperation("商家端列表")
    public Result storeList(Integer page, Integer size,
                            @ApiParam("状态（0全部 1待处理 2投诉驳回 3商家处理中 4商家已处理 5总后台已处理）") Integer status,
                            @ApiParam("商户id") Long merchantId) {
        return service.storeList(page, size, status, merchantId);
    }

    @IgnoreSecurity
    @GetMapping("/userList")
    @ApiOperation("用户端列表")
    public Result userList(Integer page, Integer size, Long userId) {
        return service.userList(page, size, userId);
    }

    @IgnoreSecurity
    @GetMapping("/find")
    @ApiOperation("查询")
    public Result findOne(Long id) {
        return service.findOne(id);
    }

    @IgnoreSecurity
    @PostMapping("/save")
    @ApiOperation("添加")
    public Result saveBody(@RequestBody SelfStoreComplain entity) {
        return service.saveBody(entity);
    }

    @IgnoreSecurity
    @PostMapping("/update")
    @ApiOperation("修改")
    public Result updateBody(@RequestBody SelfStoreComplain entity) {
        return service.updateBody(entity);
    }

    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(Long id) {
        return service.delete(id);
    }

    @GetMapping("/deal")
    @ApiOperation("处理")
    public Result deal(@ApiParam("申请id") @RequestParam Long id,
                       @ApiParam("状态（1待处理 2投诉驳回 3商家处理中 4商家已处理 5总后台已处理）") @RequestParam Integer status,
                       @ApiParam("驳回原因") @RequestParam(required = false) String refundReason) {
        return service.deal(id, status, refundReason);
    }

}
